﻿using System;
using System.Collections.Generic;
using System.Linq;
using System.Text;
using System.Threading.Tasks;

namespace StoreApp
{
    public abstract class Item
    {
        public int Price;
    }

    public class Book : Item
    {
        private string m_author;
        private string m_title;
        private string m_publisher;
        private string m_imprintDate;

        public string Author
        {
            get { return m_author; }
            protected set { m_author = value; }
        }

        public string Title
        {
            get { return m_title; }
            protected set { m_title = value; }
        }

        public string Publisher
        {
            get { return m_publisher; }
        }

        public string ImprintDate
        {
            get { return m_imprintDate; }
            set { m_imprintDate = value; }
        }

        public string FormTitle()
        {
            return Title.Trim()
                   + (Publisher != string.Empty ? Formated(Publisher) : string.Empty)
                   + (ImprintDate != string.Empty ? Formated(ImprintDate) : string.Empty);
        }

        private string Formated(string str)
        {
            return "[" + str + "]";
        }

        public Book(string author, string title, int price = 0, string publisher = "", string imprintDate = "")
        {
            Price = price;
            if (author == null)
                throw new NullReferenceException("author");
            if (title == null)
                throw new NullReferenceException("title");
            m_author = author;
            m_title = title;
            m_publisher = publisher;
            m_imprintDate = imprintDate;
        }
    }

    public class NullBook : Book
    {
        public NullBook()
            : base("", "")
        {
        }
    }
}
